package org.luxor.commons.zookeeper.watcher;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
import org.apache.curator.framework.recipes.cache.TreeCacheListener;
import org.luxor.commons.zookeeper.annotation.ZookeeperWatcher;
import org.luxor.commons.zookeeper.constant.Watcher;
import org.springframework.stereotype.Component;

@Component
@ZookeeperWatcher(value = TreeWatcher.PATH, watcher = Watcher.TreeCache)
public class TreeWatcher implements TreeCacheListener {
    public static final String PATH = "/watcher";

    @Override
    public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exception {
        System.out.println("==========TreeWatcher start==============");
        System.out.println("TreeWatcher event: " + event);
        System.out.println("==========TreeWatcher end==============");
    }
}
